﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Drawing;
using System.IO;

namespace JobSeek.Classes
{
    public class JobRepository
    {
        public static bool AddJob(Job job)
        {
            using (job_seekerEntities ctx = new job_seekerEntities())
            {
                //add a new job regarding if they are in the list or not. Every post earnsss =D

                //add job requires to access different things like location, classification. 


            }
            return false;
        }


        public static bool IsLocation(int location_id, int sub_location_id)
        {
            bool correct = false;
            using (job_seekerEntities ctx = new job_seekerEntities())
            {
                Sub_location sub_location = (from sub in ctx.Sub_location
                                             where sub.sub_loc_id == sub_location_id
                                             select sub).SingleOrDefault<Sub_location>();

                if (sub_location != null)
                {
                    //check if the location id matches the location id. 
                    if (sub_location.location_id == location_id)
                    {
                        correct = true;
                    }
                }
            }

            return correct;
        }

        public static bool IsClassification(int classification_id)
        {
            bool correct = false;
            using (job_seekerEntities ctx = new job_seekerEntities())
            {
                int classification_count = (from c in ctx.Classifications
                                            where c.classification_id == classification_id
                                            select c).Count();

                if (classification_count > 0)
                {
                    //classification Exist
                    correct = true;
                }

            }

            return correct;
        }       
    }
}